package com.yanfan.energy.domain.enums;

public enum EnergyTypeEnum {

    /**
     * 冷却水  1
     */
    CODE_COOLING_WATER(1, "冷却水"), // 软化水 也叫自来水
    TAP(2, "软化水/自来水"), PURE_WATER(3, "纯水"),

    // 电  2
    SPIKES(7, "尖电"), PEAKS(8, "峰电"), PARITY(9, "平电"), LOWEBB(10, "谷电"),

    // 气  3
    COMPRESS(4, "压缩空气"), CARBON_DIOXIDE(5, "二氧化碳"), VAPOUR(6, "蒸汽");

    private Integer code;

    private String desc;

    EnergyTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据枚举type 返回String类型
     *
     * @param type
     * @return
     */
    public static EnergyTypeEnum getEnumByType(Integer type) {
        for (EnergyTypeEnum item : EnergyTypeEnum.values()) {
            if (item.getCode().equals(type)) {
                return item;
            }
        }
        throw new RuntimeException("通过type获取枚举类时出现异常！");
    }

    /**
     * 根据枚举type 返回String类型
     *
     * @param type
     * @return
     */
    public static String getDescByType(Integer type) {
        for (EnergyTypeEnum item : EnergyTypeEnum.values()) {
            if (item.getCode().equals(type)) {
                return item.getDesc();
            }
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
